<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				$('.select-chosen').chosen();
				ligerTable = $('#table').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/${route}/getList',
					delayLoad:false,
					pageSize:20,
					columns:[
                        {display:'ID',name:'driverId',id:'driverId',align:'center',minWidth:80},
                        {display:'所属公司',name:'companyName',id:'companyName',align:'center',minWidth:100},
						{display:'手机号',name:'phoneNo',id:'phoneNo',align:'center',minWidth:100},
						{display:'身份证',name:'idCard',id:'idCard',align:'center',minWidth:150},
						{display:'真实姓名',name:'trueName',id:'trueName',align:'center',minWidth:80},
						{display:'性别',name:'sex',id:'sex',align:'center',minWidth:30},
						{display:'服务业务',name:'serviceNames',id:'serviceNames',align:'center',minWidth:120},
						{
							display:'状态',
							name:'status',
							id:'status',
							align:'center',
							minWidth:40,
							render:function(row){
						 		var status = row.status;
						 		if(status == 1){
						 			return '<span style="color:#ccc">离线</span>';
						 		}
						 		else if(status == 2){
						 			return '<span style="color:#0f0">在线</span>';
						 		}
						 		else if(status == 4){
						 			return '<span style="color:#f00">服务中</span>';
						 		}
						 		return '-';
							}
						},
						{
                            display:'审核状态',
                            name:'checkState',
                            id:'checkState',
                            align:'center',
                            minWidth:80,
                            render:function(row){
                                var status = row.checkState;
                                if(status == 1){
                                    return '<span style="color:#ccc">待审核</span>';
                                }
                                else if(status == 2){
                                    return '<span style="color:#0f0">审核通过</span>';
                                }
                                else if(status == 4){
                                    return '<span style="color:#f00">审核不通过</span>';
                                }
                                return '-';
                            }
                        },
						{
							display:'头像',
							name:'headImg',
							id:'headImg',
							align:'center',
							minWidth:120,
							render:function(row){
						 		if(row.headImg){
						 			return '<img alt="" src="'+row.headImg+'" height="40">';
						 		}
						 		return '-';
							}
						},
						{display:'绑定银行卡号',name:'bankCard',id:'bankCard',align:'center',minWidth:120},
						{display:'驾龄',name:'driveAge',id:'driveAge',align:'center',minWidth:40},
						{display:'驾驶证',name:'driveCret',id:'driveCret',align:'center',minWidth:150},
						{
                            display:'是否绑定车辆',
                            name:'bindCar',
                            id:'bindCar',
                            align:'center',
                            minWidth:70,
                            render:function(row){
                                if(row.bindCar){
                                    return '已绑定';
                                }
                                return '未绑定';
                            }
                        },
						{display:'车牌号',name:'carNo',id:'carNo',align:'center',minWidth:80},
						{display:'车品牌',name:'carBrand',id:'carBrand',align:'center',minWidth:100},
						{display:'车型号',name:'carRank',id:'carRank',align:'center',minWidth:80},
						{display:'车辆类型',name:'carType',id:'carType',align:'center',minWidth:100},
						{display:'车颜色',name:'carColor',id:'carColor',align:'center',minWidth:80},
                        {display:'车座位数',name:'carSeats',id:'carSeats',align:'center',minWidth:40},
						{
							display:'操作时间',
							name:'operateTime',
							id:'operateTime',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.operateTime > 0){
						 			return formatDate(row.operateTime * 1000);
						 		}
						 		return '-';
							}
						},
						{display:'操作人',name:'operator',id:'operator',align:'center',minWidth:80},
						{
							display:'是否启用',
							name:'enabled',
							id:'enabled',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.enabled){
						 			return '是';
						 		}
						 		return '否';
							}
						}
					],
					onDblClickRow: function (data, rowindex, rowobj){
						layer.open({
							title:'${module}',
							type:2,
							maxmin:false,
							area: ['100%', '100%'],
							content:'${base}/${route}/view/'+data.driverId
						});
					}
				});
				
				function reload(){
					if(ligerTable){
						var searchKey = $('#txtSearchKey').val();
						var companyId = $('#companyId').val();
						var serviceCode = $('#serviceCode').val();
                        var startTime = $('#txtStartTime').val();
                        var endTime = $('#txtEndTime').val();
                        ligerTable.setParm('companyId',companyId);
                        ligerTable.setParm('serviceCode',serviceCode);
                        ligerTable.setParm('startTime',startTime);
                        ligerTable.setParm('endTime',endTime);
						ligerTable.setParm('searchKey',searchKey);
						ligerTable.reload();
					}
				}
				$('#btnSearch').click(function(){
					reload();
				})
				$('#btnCarImage').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.driverId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			        	var url='${base}/carimgs/list/'+row.openId;
			            changePage(url);
			    	}
				});
				$('#btnPwd').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.driverId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var driverId = row.driverId;
			        	var url='${base}/${route}/pwd/'+driverId;
			            changePage(url);
			    	}
				});
				$('#bindCar').click(function(){
                    if(ligerTable){
                        var row = ligerTable.getSelectedRow();
                        if(!row || row.driverId < 1){
                            layer.msg('请选择行')
                            return;
                        }
                        if(row.bindCar){
                            layer.msg('该司机已绑定车辆，请勿重复绑定')
                            return;
                        }
                        var driverId = row.driverId;
                        var url='${base}/${route}/bindcar/'+driverId;
                        changePage(url);
                    }
                });
                $('#unbindCar').click(function(){
                    if(ligerTable){
                        var row = ligerTable.getSelectedRow();
                        if(!row || row.driverId < 1){
                            layer.msg('请选择行')
                            return;
                        }
                        if(!row.bindCar){
                            layer.msg('该司机未绑定车辆！')
                            return;
                        }
                        var driverId = row.driverId;
                        layer.confirm('确定要解绑车辆吗？',function(){
                            $.ajax({
                                url:'${base}/${route}/unbindCar/'+driverId,
                                type:'POST',
                                data:{},
                                dataType:'json',
                                success:function(rst){
                                    layer.alert(rst.message);
                                    if(rst.status=='OK' && ligerTable != null ){
                                        ligerTable.reload();
                                    }
                                }
                            });
                        });
                    }
                });
				$('#btnEdit').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.serviceId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var driverId = row.driverId;
			        	var url='${base}/${route}/edit/'+driverId;
			            changePage(url);
			    	}
				});
				$('#btnRemove').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.driverId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var driverId = row.driverId;
			    		layer.confirm('确定要删除吗？',function(){
			    			$.ajax({
			            		url:'${base}/${route}/remove/'+driverId,
			            		type:'POST',
			            		data:{},
			            		dataType:'json',
			            		success:function(rst){
			            			layer.alert(rst.message);
			            			if(rst.status=='OK' && ligerTable != null ){
			            				ligerTable.reload();
			            			}
			            		}
			            	});	
			    		});
			    	}
				});
			});
		//-->
		</script>
	</head>
	<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
		<div class="widget-box">
			<div class="widget-header widget-header-flat">
				<h5 class="lighter">
					<i class="fa fa-search"></i>
					${module}查询
				</h5>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="row">
                        <div class="input-daterange input-group col-sm-8">
                            <span class="input-group-addon">注册时间</span>
                            <input class="form-control date-picker" id="txtStartTime" type="text" value="${startTime}" data-date-format="yyyy-mm-dd" />
                            <span class="input-group-addon">
                                <i class="fa fa-calendar"></i>
                            </span>
                            <span class="input-group-addon">
                                <i class="fa fa-exchange"></i>
                            </span>
                            <input class="form-control date-picker" id="txtEndTime" type="text" value="${endTime}" data-date-format="yyyy-mm-dd" />
                            <span class="input-group-addon">
                                <i class="fa fa-calendar"></i>
                            </span>
                        </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="row">
                        <div class="col-sm-1 input-group">
                            <span class="input-group-addon">服务业务</span>
                            <select id="serviceCode">
                                <option value="">全部</option>
                                <#if serviceCodeList?exists && serviceCodeList?size gt 0>
                                <#list serviceCodeList as item >
                                <option value="${item.serviceCode}">${item.serviceName}</option>
                                </#list>
                                </#if>
                            </select>
                        </div>
                        <#if user?exists && companyRole?exists && user.roleId != companyRole>
                            <div class="col-sm-3 input-group">
                                <span class="input-group-addon">所属公司</span>
                                <select id="companyId" class="width-100">
                                    <option value="">全部</option>
                                    <#if companyList?exists && companyList?size gt 0>
                                    <#list companyList as item >
                                    <option value="${item.companyId}">${item.ownerName}</option>
                                    </#list>
                                    </#if>
                                </select>
                            </div>
                        </#if>
                        <div class="col-xs-5 col-sm-4">
                            <div class="input-group">
                                <span class="input-group-addon">关键字</span>
                                <input id="txtSearchKey" type="text" class="form-control search-query" placeholder="请输入关键字搜索" />
                                <span class="input-group-btn">
                                    <button id="btnSearch" type="button" class="btn btn-primary btn-sm">
                                        查询
                                        <i class="fa fa-search bigger-110"></i>
                                    </button>
                                </span>
                            </div>
                        </div>
                    </div>
				</div>
			</div>
		</div>
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">
					<i class="icon-table"></i>
					${module}列表
				</h5>
				<!--非查询者有该操作-->
				<#if user?exists && viewerRole?exists && user.roleId != viewerRole>
				<div class="widget-toolbar">
					<button id="btnCarImage" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-file-image-o"></i>车图片
					</button>
					<button id="bindCar" type="button" class="btn btn-primary btn-xs">
                        <i class="fa fa-life-bouy"></i>绑定车辆
                    </button>
                    <button id="unbindCar" type="button" class="btn btn-primary btn-xs">
                        <i class="fa fa-spoon"></i>解绑车辆
                    </button>
					<button id="btnPwd" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-key"></i>修改密码
					</button>
					<button id="btnEdit" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-check-square-o"></i>编辑
					</button>
					<button id="btnRemove" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-trash-o"></i>删除
					</button>
				</div>
				</#if>
			</div>
			<div class="widget-body">
				<div id="table"><div>
			</div>
		</div>
	</body>
</html>